//
//  FirstScrollow.m
//  AgricultureApp
//
//  Created by 米粒 on 16/7/29.
//  Copyright © 2016年 米粒. All rights reserved.
//
#import "Header.h"
#import "FirstScrollow.h"

@implementation FirstScrollow

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
-(id)initWithFrame:(CGRect)frame
{
    self=[super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        self.pagingEnabled = YES;
        self.delegate=self;
        self.showsHorizontalScrollIndicator = NO;
        self.showsVerticalScrollIndicator = NO;
        self.bounces = NO;

    }
    return self;
}
-(void)setImageWithArray:(NSArray *)imageArray
{
    self.iamgeArray=imageArray;
    self.contentSize=CGSizeMake(WIDTH*(imageArray.count+1), HEIGHT);
   [imageArray enumerateObjectsUsingBlock:^(NSString * obj, NSUInteger idx, BOOL * _Nonnull stop) {
    
       UIImageView *scrollowImg=[[UIImageView alloc] initWithFrame:CGRectMake(idx*WIDTH, 0, WIDTH, HEIGHT)];
       scrollowImg.image=[UIImage imageNamed:obj];
       [self addSubview:scrollowImg];
       
       
   }];
    
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
  
    if (scrollView.contentOffset.x==WIDTH*self.iamgeArray.count) {
        BOOL isCheckFlag=YES;
        [[NSUserDefaults standardUserDefaults]setObject:@(isCheckFlag) forKey:@"CheckFlag"];
        [self removeFromSuperview];
    }
}




@end
